aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/Kbuild9
-rw-r--r--include/linux/usb/cdc.h412
-rw-r--r--include/linux/usb/ch11.h246
-rw-r--r--include/linux/usb/f_accessory.h83
-rw-r--r--include/linux/usb/f_mtp.h75
-rw-r--r--include/linux/usb/g_printer.h35
-rw-r--r--include/linux/usb/gadgetfs.h88
-rw-r--r--include/linux/usb/langwell_otg.h139
-rw-r--r--include/linux/usb/langwell_udc.h310
-rw-r--r--include/linux/usb/midi.h112
-rw-r--r--include/linux/usb/otg_id.h58
-rw-r--r--include/linux/usb/tmc.h43
-rw-r--r--include/linux/usb/video.h568
13 files changed, 2178 insertions, 0 deletions
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
new file mode 100644
index 00000000000..ed91fb62674
--- /dev/null
+++ b/include/linux/usb/Kbuild
@@ -0,0 +1,9 @@
1header-y += audio.h
2header-y += cdc.h
3header-y += ch9.h
4header-y += ch11.h
5header-y += functionfs.h
6header-y += gadgetfs.h
7header-y += midi.h
8header-y += g_printer.h
9header-y += tmc.h
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
new file mode 100644
index 00000000000..81a927930bf
--- /dev/null
+++ b/include/linux/usb/cdc.h
@@ -0,0 +1,412 @@
1/*
2 * USB Communications Device Class (CDC) definitions
3 *
4 * CDC says how to talk to lots of different types of network adapters,
5 * notably ethernet adapters and various modems. It's used mostly with
6 * firmware based USB peripherals.
7 */
8
9#ifndef __LINUX_USB_CDC_H
10#define __LINUX_USB_CDC_H
11
12#include <linux/types.h>
13
14#define USB_CDC_SUBCLASS_ACM 0x02
15#define USB_CDC_SUBCLASS_ETHERNET 0x06
16#define USB_CDC_SUBCLASS_WHCM 0x08
17#define USB_CDC_SUBCLASS_DMM 0x09
18#define USB_CDC_SUBCLASS_MDLM 0x0a
19#define USB_CDC_SUBCLASS_OBEX 0x0b
20#define USB_CDC_SUBCLASS_EEM 0x0c
21#define USB_CDC_SUBCLASS_NCM 0x0d
22
23#define USB_CDC_PROTO_NONE 0
24
25#define USB_CDC_ACM_PROTO_AT_V25TER 1
26#define USB_CDC_ACM_PROTO_AT_PCCA101 2
27#define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3
28#define USB_CDC_ACM_PROTO_AT_GSM 4
29#define USB_CDC_ACM_PROTO_AT_3G 5
30#define USB_CDC_ACM_PROTO_AT_CDMA 6
31#define USB_CDC_ACM_PROTO_VENDOR 0xff
32
33#define USB_CDC_PROTO_EEM 7
34
35#define USB_CDC_NCM_PROTO_NTB 1
36
37/*-------------------------------------------------------------------------*/
38
39/*
40 * Class-Specific descriptors ... there are a couple dozen of them
41 */
42
43#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
44#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
45#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
46#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
47#define USB_CDC_COUNTRY_TYPE 0x07
48#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
49#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
50#define USB_CDC_WHCM_TYPE 0x11
51#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
52#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
53#define USB_CDC_DMM_TYPE 0x14
54#define USB_CDC_OBEX_TYPE 0x15
55#define USB_CDC_NCM_TYPE 0x1a
56
57/* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
58struct usb_cdc_header_desc {
59 __u8 bLength;
60 __u8 bDescriptorType;
61 __u8 bDescriptorSubType;
62
63 __le16 bcdCDC;
64} __attribute__ ((packed));
65
66/* "Call Management Descriptor" from CDC spec 5.2.3.2 */
67struct usb_cdc_call_mgmt_descriptor {
68 __u8 bLength;
69 __u8 bDescriptorType;
70 __u8 bDescriptorSubType;
71
72 __u8 bmCapabilities;
73#define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
74#define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
75
76 __u8 bDataInterface;
77} __attribute__ ((packed));
78
79/* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */
80struct usb_cdc_acm_descriptor {
81 __u8 bLength;
82 __u8 bDescriptorType;
83 __u8 bDescriptorSubType;
84
85 __u8 bmCapabilities;
86} __attribute__ ((packed));
87
88/* capabilities from 5.2.3.3 */
89
90#define USB_CDC_COMM_FEATURE 0x01
91#define USB_CDC_CAP_LINE 0x02
92#define USB_CDC_CAP_BRK 0x04
93#define USB_CDC_CAP_NOTIFY 0x08
94
95/* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
96struct usb_cdc_union_desc {
97 __u8 bLength;
98 __u8 bDescriptorType;
99 __u8 bDescriptorSubType;
100
101 __u8 bMasterInterface0;
102 __u8 bSlaveInterface0;
103 /* ... and there could be other slave interfaces */
104} __attribute__ ((packed));
105
106/* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
107struct usb_cdc_country_functional_desc {
108 __u8 bLength;
109 __u8 bDescriptorType;
110 __u8 bDescriptorSubType;
111
112 __u8 iCountryCodeRelDate;
113 __le16 wCountyCode0;
114 /* ... and there can be a lot of country codes */
115} __attribute__ ((packed));
116
117/* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
118struct usb_cdc_network_terminal_desc {
119 __u8 bLength;
120 __u8 bDescriptorType;
121 __u8 bDescriptorSubType;
122
123 __u8 bEntityId;
124 __u8 iName;
125 __u8 bChannelIndex;
126 __u8 bPhysicalInterface;
127} __attribute__ ((packed));
128
129/* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
130struct usb_cdc_ether_desc {
131 __u8 bLength;
132 __u8 bDescriptorType;
133 __u8 bDescriptorSubType;
134
135 __u8 iMACAddress;
136 __le32 bmEthernetStatistics;
137 __le16 wMaxSegmentSize;
138 __le16 wNumberMCFilters;
139 __u8 bNumberPowerFilters;
140} __attribute__ ((packed));
141
142/* "Telephone Control Model Functional Descriptor" from CDC WMC spec 6.3..3 */
143struct usb_cdc_dmm_desc {
144 __u8 bFunctionLength;
145 __u8 bDescriptorType;
146 __u8 bDescriptorSubtype;
147 __u16 bcdVersion;
148 __le16 wMaxCommand;
149} __attribute__ ((packed));
150
151/* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
152struct usb_cdc_mdlm_desc {
153 __u8 bLength;
154 __u8 bDescriptorType;
155 __u8 bDescriptorSubType;
156
157 __le16 bcdVersion;
158 __u8 bGUID[16];
159} __attribute__ ((packed));
160
161/* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
162struct usb_cdc_mdlm_detail_desc {
163 __u8 bLength;
164 __u8 bDescriptorType;
165 __u8 bDescriptorSubType;
166
167 /* type is associated with mdlm_desc.bGUID */
168 __u8 bGuidDescriptorType;
169 __u8 bDetailData[0];
170} __attribute__ ((packed));
171
172/* "OBEX Control Model Functional Descriptor" */
173struct usb_cdc_obex_desc {
174 __u8 bLength;
175 __u8 bDescriptorType;
176 __u8 bDescriptorSubType;
177
178 __le16 bcdVersion;
179} __attribute__ ((packed));
180
181/* "NCM Control Model Functional Descriptor" */
182struct usb_cdc_ncm_desc {
183 __u8 bLength;
184 __u8 bDescriptorType;
185 __u8 bDescriptorSubType;
186
187 __le16 bcdNcmVersion;
188 __u8 bmNetworkCapabilities;
189} __attribute__ ((packed));
190/*-------------------------------------------------------------------------*/
191
192/*
193 * Class-Specific Control Requests (6.2)
194 *
195 * section 3.6.2.1 table 4 has the ACM profile, for modems.
196 * section 3.8.2 table 10 has the ethernet profile.
197 *
198 * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
199 * heavily dependent on the encapsulated (proprietary) command mechanism.
200 */
201
202#define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
203#define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
204#define USB_CDC_REQ_SET_LINE_CODING 0x20
205#define USB_CDC_REQ_GET_LINE_CODING 0x21
206#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
207#define USB_CDC_REQ_SEND_BREAK 0x23
208#define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
209#define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
210#define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
211#define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
212#define USB_CDC_GET_ETHERNET_STATISTIC 0x44
213#define USB_CDC_GET_NTB_PARAMETERS 0x80
214#define USB_CDC_GET_NET_ADDRESS 0x81
215#define USB_CDC_SET_NET_ADDRESS 0x82
216#define USB_CDC_GET_NTB_FORMAT 0x83
217#define USB_CDC_SET_NTB_FORMAT 0x84
218#define USB_CDC_GET_NTB_INPUT_SIZE 0x85
219#define USB_CDC_SET_NTB_INPUT_SIZE 0x86
220#define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87
221#define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88
222#define USB_CDC_GET_CRC_MODE 0x89
223#define USB_CDC_SET_CRC_MODE 0x8a
224
225/* Line Coding Structure from CDC spec 6.2.13 */
226struct usb_cdc_line_coding {
227 __le32 dwDTERate;
228 __u8 bCharFormat;
229#define USB_CDC_1_STOP_BITS 0
230#define USB_CDC_1_5_STOP_BITS 1
231#define USB_CDC_2_STOP_BITS 2
232
233 __u8 bParityType;
234#define USB_CDC_NO_PARITY 0
235#define USB_CDC_ODD_PARITY 1
236#define USB_CDC_EVEN_PARITY 2
237#define USB_CDC_MARK_PARITY 3
238#define USB_CDC_SPACE_PARITY 4
239
240 __u8 bDataBits;
241} __attribute__ ((packed));
242
243/* table 62; bits in multicast filter */
244#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
245#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
246#define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
247#define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
248#define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
249
250
251/*-------------------------------------------------------------------------*/
252
253/*
254 * Class-Specific Notifications (6.3) sent by interrupt transfers
255 *
256 * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
257 * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
258 * RNDIS also defines its own bit-incompatible notifications
259 */
260
261#define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
262#define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
263#define USB_CDC_NOTIFY_SERIAL_STATE 0x20
264#define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a
265
266struct usb_cdc_notification {
267 __u8 bmRequestType;
268 __u8 bNotificationType;
269 __le16 wValue;
270 __le16 wIndex;
271 __le16 wLength;
272} __attribute__ ((packed));
273
274struct usb_cdc_speed_change {
275 __le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */
276 __le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */
277} __attribute__ ((packed));
278
279/*-------------------------------------------------------------------------*/
280
281/*
282 * Class Specific structures and constants
283 *
284 * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1
285 *
286 */
287
288struct usb_cdc_ncm_ntb_parameters {
289 __le16 wLength;
290 __le16 bmNtbFormatsSupported;
291 __le32 dwNtbInMaxSize;
292 __le16 wNdpInDivisor;
293 __le16 wNdpInPayloadRemainder;
294 __le16 wNdpInAlignment;
295 __le16 wPadding1;
296 __le32 dwNtbOutMaxSize;
297 __le16 wNdpOutDivisor;
298 __le16 wNdpOutPayloadRemainder;
299 __le16 wNdpOutAlignment;
300 __le16 wNtbOutMaxDatagrams;
301} __attribute__ ((packed));
302
303/*
304 * CDC NCM transfer headers, CDC NCM subclass 3.2
305 */
306
307#define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */
308#define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */
309
310struct usb_cdc_ncm_nth16 {
311 __le32 dwSignature;
312 __le16 wHeaderLength;
313 __le16 wSequence;
314 __le16 wBlockLength;
315 __le16 wNdpIndex;
316} __attribute__ ((packed));
317
318struct usb_cdc_ncm_nth32 {
319 __le32 dwSignature;
320 __le16 wHeaderLength;
321 __le16 wSequence;
322 __le32 dwBlockLength;
323 __le32 dwNdpIndex;
324} __attribute__ ((packed));
325
326/*
327 * CDC NCM datagram pointers, CDC NCM subclass 3.3
328 */
329
330#define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */
331#define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */
332#define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */
333#define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */
334
335/* 16-bit NCM Datagram Pointer Entry */
336struct usb_cdc_ncm_dpe16 {
337 __le16 wDatagramIndex;
338 __le16 wDatagramLength;
339} __attribute__((__packed__));
340
341/* 16-bit NCM Datagram Pointer Table */
342struct usb_cdc_ncm_ndp16 {
343 __le32 dwSignature;
344 __le16 wLength;
345 __le16 wNextNdpIndex;
346 struct usb_cdc_ncm_dpe16 dpe16[0];
347} __attribute__ ((packed));
348
349/* 32-bit NCM Datagram Pointer Entry */
350struct usb_cdc_ncm_dpe32 {
351 __le32 dwDatagramIndex;
352 __le32 dwDatagramLength;
353} __attribute__((__packed__));
354
355/* 32-bit NCM Datagram Pointer Table */
356struct usb_cdc_ncm_ndp32 {
357 __le32 dwSignature;
358 __le16 wLength;
359 __le16 wReserved6;
360 __le32 dwNextNdpIndex;
361 __le32 dwReserved12;
362 struct usb_cdc_ncm_dpe32 dpe32[0];
363} __attribute__ ((packed));
364
365/* CDC NCM subclass 3.2.1 and 3.2.2 */
366#define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C
367#define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010
368
369/* CDC NCM subclass 3.3.3 Datagram Formatting */
370#define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30
371#define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31
372
373/* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
374#define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00
375#define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE
376
377/* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
378#define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0)
379#define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1)
380#define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2)
381#define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3)
382#define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4)
383#define USB_CDC_NCM_NCAP_NTB_INPUT_SIZE (1 << 5)
384
385/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
386#define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0)
387#define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1)
388
389/* CDC NCM subclass Table 6-3: NTB Parameter Structure */
390#define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04
391#define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C
392
393/* CDC NCM subclass 6.2.5 SetNtbFormat */
394#define USB_CDC_NCM_NTB16_FORMAT 0x00
395#define USB_CDC_NCM_NTB32_FORMAT 0x01
396
397/* CDC NCM subclass 6.2.7 SetNtbInputSize */
398#define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048
399#define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048
400
401/* NTB Input Size Structure */
402struct usb_cdc_ncm_ndp_input_size {
403 __le32 dwNtbInMaxSize;
404 __le16 wNtbInMaxDatagrams;
405 __le16 wReserved;
406} __attribute__ ((packed));
407
408/* CDC NCM subclass 6.2.11 SetCrcMode */
409#define USB_CDC_NCM_CRC_NOT_APPENDED 0x00
410#define USB_CDC_NCM_CRC_APPENDED 0x01
411
412#endif /* __LINUX_USB_CDC_H */
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h
new file mode 100644
index 00000000000..4ebaf082417
--- /dev/null
+++ b/include/linux/usb/ch11.h
@@ -0,0 +1,246 @@
1/*
2 * This file holds Hub protocol constants and data structures that are
3 * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
4 *
5 * It is used/shared between the USB core, the HCDs and couple of other USB
6 * drivers.
7 */
8
9#ifndef __LINUX_CH11_H
10#define __LINUX_CH11_H
11
12#include <linux/types.h> /* __u8 etc */
13
14/*
15 * Hub request types
16 */
17
18#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
19#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
20
21/*
22 * Hub class requests
23 * See USB 2.0 spec Table 11-16
24 */
25#define HUB_CLEAR_TT_BUFFER 8
26#define HUB_RESET_TT 9
27#define HUB_GET_TT_STATE 10
28#define HUB_STOP_TT 11
29#define HUB_SET_DEPTH 12
30
31/*
32 * Hub class additional requests defined by USB 3.0 spec
33 * See USB 3.0 spec Table 10-6
34 */
35#define HUB_SET_DEPTH 12
36#define HUB_GET_PORT_ERR_COUNT 13
37
38/*
39 * Hub Class feature numbers
40 * See USB 2.0 spec Table 11-17
41 */
42#define C_HUB_LOCAL_POWER 0
43#define C_HUB_OVER_CURRENT 1
44
45/*
46 * Port feature numbers
47 * See USB 2.0 spec Table 11-17
48 */
49#define USB_PORT_FEAT_CONNECTION 0
50#define USB_PORT_FEAT_ENABLE 1
51#define USB_PORT_FEAT_SUSPEND 2 /* L2 suspend */
52#define USB_PORT_FEAT_OVER_CURRENT 3
53#define USB_PORT_FEAT_RESET 4
54#define USB_PORT_FEAT_L1 5 /* L1 suspend */
55#define USB_PORT_FEAT_POWER 8
56#define USB_PORT_FEAT_LOWSPEED 9 /* Should never be used */
57#define USB_PORT_FEAT_C_CONNECTION 16
58#define USB_PORT_FEAT_C_ENABLE 17
59#define USB_PORT_FEAT_C_SUSPEND 18
60#define USB_PORT_FEAT_C_OVER_CURRENT 19
61#define USB_PORT_FEAT_C_RESET 20
62#define USB_PORT_FEAT_TEST 21
63#define USB_PORT_FEAT_INDICATOR 22
64#define USB_PORT_FEAT_C_PORT_L1 23
65#define USB_PORT_FEAT_C_PORT_LINK_STATE 25
66#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR 26
67#define USB_PORT_FEAT_PORT_REMOTE_WAKE_MASK 27
68#define USB_PORT_FEAT_BH_PORT_RESET 28
69#define USB_PORT_FEAT_C_BH_PORT_RESET 29
70#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
71
72/*
73 * Port feature selectors added by USB 3.0 spec.
74 * See USB 3.0 spec Table 10-7
75 */
76#define USB_PORT_FEAT_LINK_STATE 5
77#define USB_PORT_FEAT_U1_TIMEOUT 23
78#define USB_PORT_FEAT_U2_TIMEOUT 24
79#define USB_PORT_FEAT_C_LINK_STATE 25
80#define USB_PORT_FEAT_C_CONFIG_ERR 26
81#define USB_PORT_FEAT_REMOTE_WAKE_MASK 27
82#define USB_PORT_FEAT_BH_PORT_RESET 28
83#define USB_PORT_FEAT_C_BH_PORT_RESET 29
84#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
85
86/*
87 * Hub Status and Hub Change results
88 * See USB 2.0 spec Table 11-19 and Table 11-20
89 */
90struct usb_port_status {
91 __le16 wPortStatus;
92 __le16 wPortChange;
93} __attribute__ ((packed));
94
95/*
96 * wPortStatus bit field
97 * See USB 2.0 spec Table 11-21
98 */
99#define USB_PORT_STAT_CONNECTION 0x0001
100#define USB_PORT_STAT_ENABLE 0x0002
101#define USB_PORT_STAT_SUSPEND 0x0004
102#define USB_PORT_STAT_OVERCURRENT 0x0008
103#define USB_PORT_STAT_RESET 0x0010
104#define USB_PORT_STAT_L1 0x0020
105/* bits 6 to 7 are reserved */
106#define USB_PORT_STAT_POWER 0x0100
107#define USB_PORT_STAT_LOW_SPEED 0x0200
108#define USB_PORT_STAT_HIGH_SPEED 0x0400
109#define USB_PORT_STAT_TEST 0x0800
110#define USB_PORT_STAT_INDICATOR 0x1000
111/* bits 13 to 15 are reserved */
112
113/*
114 * Additions to wPortStatus bit field from USB 3.0
115 * See USB 3.0 spec Table 10-10
116 */
117#define USB_PORT_STAT_LINK_STATE 0x01e0
118#define USB_SS_PORT_STAT_POWER 0x0200
119#define USB_SS_PORT_STAT_SPEED 0x1c00
120#define USB_PORT_STAT_SPEED_5GBPS 0x0000
121/* Valid only if port is enabled */
122/* Bits that are the same from USB 2.0 */
123#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION | \
124 USB_PORT_STAT_ENABLE | \
125 USB_PORT_STAT_OVERCURRENT | \
126 USB_PORT_STAT_RESET)
127
128/*
129 * Definitions for PORT_LINK_STATE values
130 * (bits 5-8) in wPortStatus
131 */
132#define USB_SS_PORT_LS_U0 0x0000
133#define USB_SS_PORT_LS_U1 0x0020
134#define USB_SS_PORT_LS_U2 0x0040
135#define USB_SS_PORT_LS_U3 0x0060
136#define USB_SS_PORT_LS_SS_DISABLED 0x0080
137#define USB_SS_PORT_LS_RX_DETECT 0x00a0
138#define USB_SS_PORT_LS_SS_INACTIVE 0x00c0
139#define USB_SS_PORT_LS_POLLING 0x00e0
140#define USB_SS_PORT_LS_RECOVERY 0x0100
141#define USB_SS_PORT_LS_HOT_RESET 0x0120
142#define USB_SS_PORT_LS_COMP_MOD 0x0140
143#define USB_SS_PORT_LS_LOOPBACK 0x0160
144
145/*
146 * wPortChange bit field
147 * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
148 * Bits 0 to 5 shown, bits 6 to 15 are reserved
149 */
150#define USB_PORT_STAT_C_CONNECTION 0x0001
151#define USB_PORT_STAT_C_ENABLE 0x0002
152#define USB_PORT_STAT_C_SUSPEND 0x0004
153#define USB_PORT_STAT_C_OVERCURRENT 0x0008
154#define USB_PORT_STAT_C_RESET 0x0010
155#define USB_PORT_STAT_C_L1 0x0020
156/*
157 * USB 3.0 wPortChange bit fields
158 * See USB 3.0 spec Table 10-11
159 */
160#define USB_PORT_STAT_C_BH_RESET 0x0020
161#define USB_PORT_STAT_C_LINK_STATE 0x0040
162#define USB_PORT_STAT_C_CONFIG_ERROR 0x0080
163
164/*
165 * wHubCharacteristics (masks)
166 * See USB 2.0 spec Table 11-13, offset 3
167 */
168#define HUB_CHAR_LPSM 0x0003 /* D1 .. D0 */
169#define HUB_CHAR_COMPOUND 0x0004 /* D2 */
170#define HUB_CHAR_OCPM 0x0018 /* D4 .. D3 */
171#define HUB_CHAR_TTTT 0x0060 /* D6 .. D5 */
172#define HUB_CHAR_PORTIND 0x0080 /* D7 */
173
174struct usb_hub_status {
175 __le16 wHubStatus;
176 __le16 wHubChange;
177} __attribute__ ((packed));
178
179/*
180 * Hub Status & Hub Change bit masks
181 * See USB 2.0 spec Table 11-19 and Table 11-20
182 * Bits 0 and 1 for wHubStatus and wHubChange
183 * Bits 2 to 15 are reserved for both
184 */
185#define HUB_STATUS_LOCAL_POWER 0x0001
186#define HUB_STATUS_OVERCURRENT 0x0002
187#define HUB_CHANGE_LOCAL_POWER 0x0001
188#define HUB_CHANGE_OVERCURRENT 0x0002
189
190
191/*
192 * Hub descriptor
193 * See USB 2.0 spec Table 11-13
194 */
195
196#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
197#define USB_DT_SS_HUB (USB_TYPE_CLASS | 0x0a)
198#define USB_DT_HUB_NONVAR_SIZE 7
199#define USB_DT_SS_HUB_SIZE 12
200
201struct usb_hub_descriptor {
202 __u8 bDescLength;
203 __u8 bDescriptorType;
204 __u8 bNbrPorts;
205 __le16 wHubCharacteristics;
206 __u8 bPwrOn2PwrGood;
207 __u8 bHubContrCurrent;
208
209 /* 2.0 and 3.0 hubs differ here */
210 union {
211 struct {
212 /* add 1 bit for hub status change; round to bytes */
213 __u8 DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
214 __u8 PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
215 } __attribute__ ((packed)) hs;
216
217 struct {
218 __u8 bHubHdrDecLat;
219 __u16 wHubDelay;
220 __u16 DeviceRemovable;
221 } __attribute__ ((packed)) ss;
222 } u;
223} __attribute__ ((packed));
224
225/* port indicator status selectors, tables 11-7 and 11-25 */
226#define HUB_LED_AUTO 0
227#define HUB_LED_AMBER 1
228#define HUB_LED_GREEN 2
229#define HUB_LED_OFF 3
230
231enum hub_led_mode {
232 INDICATOR_AUTO = 0,
233 INDICATOR_CYCLE,
234 /* software blinks for attention: software, hardware, reserved */
235 INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
236 INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
237 INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
238} __attribute__ ((packed));
239
240/* Transaction Translator Think Times, in bits */
241#define HUB_TTTT_8_BITS 0x00
242#define HUB_TTTT_16_BITS 0x20
243#define HUB_TTTT_24_BITS 0x40
244#define HUB_TTTT_32_BITS 0x60
245
246#endif /* __LINUX_CH11_H */
diff --git a/include/linux/usb/f_accessory.h b/include/linux/usb/f_accessory.h
new file mode 100644
index 00000000000..5b2dcf9728e
--- /dev/null
+++ b/include/linux/usb/f_accessory.h
@@ -0,0 +1,83 @@
1/*
2 * Gadget Function Driver for Android USB accessories
3 *
4 * Copyright (C) 2011 Google, Inc.
5 * Author: Mike Lockwood <lockwood@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef __LINUX_USB_F_ACCESSORY_H
19#define __LINUX_USB_F_ACCESSORY_H
20
21/* Use Google Vendor ID when in accessory mode */
22#define USB_ACCESSORY_VENDOR_ID 0x18D1
23
24
25/* Product ID to use when in accessory mode */
26#define USB_ACCESSORY_PRODUCT_ID 0x2D00
27
28/* Product ID to use when in accessory mode and adb is enabled */
29#define USB_ACCESSORY_ADB_PRODUCT_ID 0x2D01
30
31/* Indexes for strings sent by the host via ACCESSORY_SEND_STRING */
32#define ACCESSORY_STRING_MANUFACTURER 0
33#define ACCESSORY_STRING_MODEL 1
34#define ACCESSORY_STRING_DESCRIPTION 2
35#define ACCESSORY_STRING_VERSION 3
36#define ACCESSORY_STRING_URI 4
37#define ACCESSORY_STRING_SERIAL 5
38
39/* Control request for retrieving device's protocol version (currently 1)
40 *
41 * requestType: USB_DIR_IN | USB_TYPE_VENDOR
42 * request: ACCESSORY_GET_PROTOCOL
43 * value: 0
44 * index: 0
45 * data version number (16 bits little endian)
46 */
47#define ACCESSORY_GET_PROTOCOL 51
48
49/* Control request for host to send a string to the device
50 *
51 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR
52 * request: ACCESSORY_SEND_STRING
53 * value: 0
54 * index: string ID
55 * data zero terminated UTF8 string
56 *
57 * The device can later retrieve these strings via the
58 * ACCESSORY_GET_STRING_* ioctls
59 */
60#define ACCESSORY_SEND_STRING 52
61
62/* Control request for starting device in accessory mode.
63 * The host sends this after setting all its strings to the device.
64 *
65 * requestType: USB_DIR_OUT | USB_TYPE_VENDOR
66 * request: ACCESSORY_START
67 * value: 0
68 * index: 0
69 * data none
70 */
71#define ACCESSORY_START 53
72
73/* ioctls for retrieving strings set by the host */
74#define ACCESSORY_GET_STRING_MANUFACTURER _IOW('M', 1, char[256])
75#define ACCESSORY_GET_STRING_MODEL _IOW('M', 2, char[256])
76#define ACCESSORY_GET_STRING_DESCRIPTION _IOW('M', 3, char[256])
77#define ACCESSORY_GET_STRING_VERSION _IOW('M', 4, char[256])
78#define ACCESSORY_GET_STRING_URI _IOW('M', 5, char[256])
79#define ACCESSORY_GET_STRING_SERIAL _IOW('M', 6, char[256])
80/* returns 1 if there is a start request pending */
81#define ACCESSORY_IS_START_REQUESTED _IO('M', 7)
82
83#endif /* __LINUX_USB_F_ACCESSORY_H */
diff --git a/include/linux/usb/f_mtp.h b/include/linux/usb/f_mtp.h
new file mode 100644
index 00000000000..7422b17c6eb
--- /dev/null
+++ b/include/linux/usb/f_mtp.h
@@ -0,0 +1,75 @@
1/*
2 * Gadget Function Driver for MTP
3 *
4 * Copyright (C) 2010 Google, Inc.
5 * Author: Mike Lockwood <lockwood@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef __LINUX_USB_F_MTP_H
19#define __LINUX_USB_F_MTP_H
20
21#include <linux/ioctl.h>
22
23#ifdef __KERNEL__
24
25struct mtp_data_header {
26 /* length of packet, including this header */
27 uint32_t length;
28 /* container type (2 for data packet) */
29 uint16_t type;
30 /* MTP command code */
31 uint16_t command;
32 /* MTP transaction ID */
33 uint32_t transaction_id;
34};
35
36#endif /* __KERNEL__ */
37
38struct mtp_file_range {
39 /* file descriptor for file to transfer */
40 int fd;
41 /* offset in file for start of transfer */
42 loff_t offset;
43 /* number of bytes to transfer */
44 int64_t length;
45 /* MTP command ID for data header,
46 * used only for MTP_SEND_FILE_WITH_HEADER
47 */
48 uint16_t command;
49 /* MTP transaction ID for data header,
50 * used only for MTP_SEND_FILE_WITH_HEADER
51 */
52 uint32_t transaction_id;
53};
54
55struct mtp_event {
56 /* size of the event */
57 size_t length;
58 /* event data to send */
59 void *data;
60};
61
62/* Sends the specified file range to the host */
63#define MTP_SEND_FILE _IOW('M', 0, struct mtp_file_range)
64/* Receives data from the host and writes it to a file.
65 * The file is created if it does not exist.
66 */
67#define MTP_RECEIVE_FILE _IOW('M', 1, struct mtp_file_range)
68/* Sends an event to the host via the interrupt endpoint */
69#define MTP_SEND_EVENT _IOW('M', 3, struct mtp_event)
70/* Sends the specified file range to the host,
71 * with a 12 byte MTP data packet header at the beginning.
72 */
73#define MTP_SEND_FILE_WITH_HEADER _IOW('M', 4, struct mtp_file_range)
74
75#endif /* __LINUX_USB_F_MTP_H */
diff --git a/include/linux/usb/g_printer.h b/include/linux/usb/g_printer.h
new file mode 100644
index 00000000000..6178fde50f7
--- /dev/null
+++ b/include/linux/usb/g_printer.h
@@ -0,0 +1,35 @@
1/*
2 * g_printer.h -- Header file for USB Printer gadget driver
3 *
4 * Copyright (C) 2007 Craig W. Nadler
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __LINUX_USB_G_PRINTER_H
22#define __LINUX_USB_G_PRINTER_H
23
24#define PRINTER_NOT_ERROR 0x08
25#define PRINTER_SELECTED 0x10
26#define PRINTER_PAPER_EMPTY 0x20
27
28/* The 'g' code is also used by gadgetfs ioctl requests.
29 * Don't add any colliding codes to either driver, and keep
30 * them in unique ranges (size 0x20 for now).
31 */
32#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char)
33#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
34
35#endif /* __LINUX_USB_G_PRINTER_H */
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
new file mode 100644
index 00000000000..0bb12e0d4f8
--- /dev/null
+++ b/include/linux/usb/gadgetfs.h
@@ -0,0 +1,88 @@
1/*
2 * Filesystem based user-mode API to USB Gadget controller hardware
3 *
4 * Other than ep0 operations, most things are done by read() and write()
5 * on endpoint files found in one directory. They are configured by
6 * writing descriptors, and then may be used for normal stream style
7 * i/o requests. When ep0 is configured, the device can enumerate;
8 * when it's closed, the device disconnects from usb. Operations on
9 * ep0 require ioctl() operations.
10 *
11 * Configuration and device descriptors get written to /dev/gadget/$CHIP,
12 * which may then be used to read usb_gadgetfs_event structs. The driver
13 * may activate endpoints as it handles SET_CONFIGURATION setup events,
14 * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT
15 * then performing data transfers by reading or writing.
16 */
17
18#ifndef __LINUX_USB_GADGETFS_H
19#define __LINUX_USB_GADGETFS_H
20
21#include <linux/types.h>
22#include <linux/ioctl.h>
23
24#include <linux/usb/ch9.h>
25
26/*
27 * Events are delivered on the ep0 file descriptor, when the user mode driver
28 * reads from this file descriptor after writing the descriptors. Don't
29 * stop polling this descriptor.
30 */
31
32enum usb_gadgetfs_event_type {
33 GADGETFS_NOP = 0,
34
35 GADGETFS_CONNECT,
36 GADGETFS_DISCONNECT,
37 GADGETFS_SETUP,
38 GADGETFS_SUSPEND,
39 /* and likely more ! */
40};
41
42/* NOTE: this structure must stay the same size and layout on
43 * both 32-bit and 64-bit kernels.
44 */
45struct usb_gadgetfs_event {
46 union {
47 /* NOP, DISCONNECT, SUSPEND: nothing
48 * ... some hardware can't report disconnection
49 */
50
51 /* CONNECT: just the speed */
52 enum usb_device_speed speed;
53
54 /* SETUP: packet; DATA phase i/o precedes next event
55 *(setup.bmRequestType & USB_DIR_IN) flags direction
56 * ... includes SET_CONFIGURATION, SET_INTERFACE
57 */
58 struct usb_ctrlrequest setup;
59 } u;
60 enum usb_gadgetfs_event_type type;
61};
62
63
64/* The 'g' code is also used by printer gadget ioctl requests.
65 * Don't add any colliding codes to either driver, and keep
66 * them in unique ranges (size 0x20 for now).
67 */
68
69/* endpoint ioctls */
70
71/* IN transfers may be reported to the gadget driver as complete
72 * when the fifo is loaded, before the host reads the data;
73 * OUT transfers may be reported to the host's "client" driver as
74 * complete when they're sitting in the FIFO unread.
75 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
76 * (needed for precise fault handling, when the hardware allows it)
77 */
78#define GADGETFS_FIFO_STATUS _IO('g', 1)
79
80/* discards any unclaimed data in the fifo. */
81#define GADGETFS_FIFO_FLUSH _IO('g', 2)
82
83/* resets endpoint halt+toggle; used to implement set_interface.
84 * some hardware (like pxa2xx) can't support this.
85 */
86#define GADGETFS_CLEAR_HALT _IO('g', 3)
87
88#endif /* __LINUX_USB_GADGETFS_H */
diff --git a/include/linux/usb/langwell_otg.h b/include/linux/usb/langwell_otg.h
new file mode 100644
index 00000000000..51f17b16d31
--- /dev/null
+++ b/include/linux/usb/langwell_otg.h
@@ -0,0 +1,139 @@
1/*
2 * Intel Langwell USB OTG transceiver driver
3 * Copyright (C) 2008 - 2010, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __LANGWELL_OTG_H
21#define __LANGWELL_OTG_H
22
23#include <linux/usb/intel_mid_otg.h>
24
25#define CI_USBCMD 0x30
26# define USBCMD_RST BIT(1)
27# define USBCMD_RS BIT(0)
28#define CI_USBSTS 0x34
29# define USBSTS_SLI BIT(8)
30# define USBSTS_URI BIT(6)
31# define USBSTS_PCI BIT(2)
32#define CI_PORTSC1 0x74
33# define PORTSC_PP BIT(12)
34# define PORTSC_LS (BIT(11) | BIT(10))
35# define PORTSC_SUSP BIT(7)
36# define PORTSC_CCS BIT(0)
37#define CI_HOSTPC1 0xb4
38# define HOSTPC1_PHCD BIT(22)
39#define CI_OTGSC 0xf4
40# define OTGSC_DPIE BIT(30)
41# define OTGSC_1MSE BIT(29)
42# define OTGSC_BSEIE BIT(28)
43# define OTGSC_BSVIE BIT(27)
44# define OTGSC_ASVIE BIT(26)
45# define OTGSC_AVVIE BIT(25)
46# define OTGSC_IDIE BIT(24)
47# define OTGSC_DPIS BIT(22)
48# define OTGSC_1MSS BIT(21)
49# define OTGSC_BSEIS BIT(20)
50# define OTGSC_BSVIS BIT(19)
51# define OTGSC_ASVIS BIT(18)
52# define OTGSC_AVVIS BIT(17)
53# define OTGSC_IDIS BIT(16)
54# define OTGSC_DPS BIT(14)
55# define OTGSC_1MST BIT(13)
56# define OTGSC_BSE BIT(12)
57# define OTGSC_BSV BIT(11)
58# define OTGSC_ASV BIT(10)
59# define OTGSC_AVV BIT(9)
60# define OTGSC_ID BIT(8)
61# define OTGSC_HABA BIT(7)
62# define OTGSC_HADP BIT(6)
63# define OTGSC_IDPU BIT(5)
64# define OTGSC_DP BIT(4)
65# define OTGSC_OT BIT(3)
66# define OTGSC_HAAR BIT(2)
67# define OTGSC_VC BIT(1)
68# define OTGSC_VD BIT(0)
69# define OTGSC_INTEN_MASK (0x7f << 24)
70# define OTGSC_INT_MASK (0x5f << 24)
71# define OTGSC_INTSTS_MASK (0x7f << 16)
72#define CI_USBMODE 0xf8
73# define USBMODE_CM (BIT(1) | BIT(0))
74# define USBMODE_IDLE 0
75# define USBMODE_DEVICE 0x2
76# define USBMODE_HOST 0x3
77#define USBCFG_ADDR 0xff10801c
78#define USBCFG_LEN 4
79# define USBCFG_VBUSVAL BIT(14)
80# define USBCFG_AVALID BIT(13)
81# define USBCFG_BVALID BIT(12)
82# define USBCFG_SESEND BIT(11)
83
84#define INTR_DUMMY_MASK (USBSTS_SLI | USBSTS_URI | USBSTS_PCI)
85
86enum langwell_otg_timer_type {
87 TA_WAIT_VRISE_TMR,
88 TA_WAIT_BCON_TMR,
89 TA_AIDL_BDIS_TMR,
90 TB_ASE0_BRST_TMR,
91 TB_SE0_SRP_TMR,
92 TB_SRP_INIT_TMR,
93 TB_SRP_FAIL_TMR,
94 TB_BUS_SUSPEND_TMR
95};
96
97#define TA_WAIT_VRISE 100
98#define TA_WAIT_BCON 30000
99#define TA_AIDL_BDIS 15000
100#define TB_ASE0_BRST 5000
101#define TB_SE0_SRP 2
102#define TB_SRP_INIT 100
103#define TB_SRP_FAIL 5500
104#define TB_BUS_SUSPEND 500
105
106struct langwell_otg_timer {
107 unsigned long expires; /* Number of count increase to timeout */
108 unsigned long count; /* Tick counter */
109 void (*function)(unsigned long); /* Timeout function */
110 unsigned long data; /* Data passed to function */
111 struct list_head list;
112};
113
114struct langwell_otg {
115 struct intel_mid_otg_xceiv iotg;
116 struct device *dev;
117
118 void __iomem *usbcfg; /* SCCBUSB config Reg */
119
120 unsigned region;
121 unsigned cfg_region;
122
123 struct work_struct work;
124 struct workqueue_struct *qwork;
125 struct timer_list hsm_timer;
126
127 spinlock_t lock;
128 spinlock_t wq_lock;
129
130 struct notifier_block iotg_notifier;
131};
132
133static inline
134struct langwell_otg *mid_xceiv_to_lnw(struct intel_mid_otg_xceiv *iotg)
135{
136 return container_of(iotg, struct langwell_otg, iotg);
137}
138
139#endif /* __LANGWELL_OTG_H__ */
diff --git a/include/linux/usb/langwell_udc.h b/include/linux/usb/langwell_udc.h
new file mode 100644
index 00000000000..2d2d1bbad9d
--- /dev/null
+++ b/include/linux/usb/langwell_udc.h
@@ -0,0 +1,310 @@
1/*
2 * Intel Langwell USB Device Controller driver
3 * Copyright (C) 2008-2009, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20#ifndef __LANGWELL_UDC_H
21#define __LANGWELL_UDC_H
22
23
24/* MACRO defines */
25#define CAP_REG_OFFSET 0x0
26#define OP_REG_OFFSET 0x28
27
28#define DMA_ADDR_INVALID (~(dma_addr_t)0)
29
30#define DQH_ALIGNMENT 2048
31#define DTD_ALIGNMENT 64
32#define DMA_BOUNDARY 4096
33
34#define EP0_MAX_PKT_SIZE 64
35#define EP_DIR_IN 1
36#define EP_DIR_OUT 0
37
38#define FLUSH_TIMEOUT 1000
39#define RESET_TIMEOUT 1000
40#define SETUPSTAT_TIMEOUT 100
41#define PRIME_TIMEOUT 100
42
43
44/* device memory space registers */
45
46/* Capability Registers, BAR0 + CAP_REG_OFFSET */
47struct langwell_cap_regs {
48 /* offset: 0x0 */
49 u8 caplength; /* offset of Operational Register */
50 u8 _reserved3;
51 u16 hciversion; /* H: BCD encoding of host version */
52 u32 hcsparams; /* H: host port steering logic capability */
53 u32 hccparams; /* H: host multiple mode control capability */
54#define HCC_LEN BIT(17) /* Link power management (LPM) capability */
55 u8 _reserved4[0x20-0xc];
56 /* offset: 0x20 */
57 u16 dciversion; /* BCD encoding of device version */
58 u8 _reserved5[0x24-0x22];
59 u32 dccparams; /* overall device controller capability */
60#define HOSTCAP BIT(8) /* host capable */
61#define DEVCAP BIT(7) /* device capable */
62#define DEN(d) \
63 (((d)>>0)&0x1f) /* bits 4:0, device endpoint number */
64} __attribute__ ((packed));
65
66
67/* Operational Registers, BAR0 + OP_REG_OFFSET */
68struct langwell_op_regs {
69 /* offset: 0x28 */
70 u32 extsts;
71#define EXTS_TI1 BIT(4) /* general purpose timer interrupt 1 */
72#define EXTS_TI1TI0 BIT(3) /* general purpose timer interrupt 0 */
73#define EXTS_TI1UPI BIT(2) /* USB host periodic interrupt */
74#define EXTS_TI1UAI BIT(1) /* USB host asynchronous interrupt */
75#define EXTS_TI1NAKI BIT(0) /* NAK interrupt */
76 u32 extintr;
77#define EXTI_TIE1 BIT(4) /* general purpose timer interrupt enable 1 */
78#define EXTI_TIE0 BIT(3) /* general purpose timer interrupt enable 0 */
79#define EXTI_UPIE BIT(2) /* USB host periodic interrupt enable */
80#define EXTI_UAIE BIT(1) /* USB host asynchronous interrupt enable */
81#define EXTI_NAKE BIT(0) /* NAK interrupt enable */
82 /* offset: 0x30 */
83 u32 usbcmd;
84#define CMD_HIRD(u) \
85 (((u)>>24)&0xf) /* bits 27:24, host init resume duration */
86#define CMD_ITC(u) \
87 (((u)>>16)&0xff) /* bits 23:16, interrupt threshold control */
88#define CMD_PPE BIT(15) /* per-port change events enable */
89#define CMD_ATDTW BIT(14) /* add dTD tripwire */
90#define CMD_SUTW BIT(13) /* setup tripwire */
91#define CMD_ASPE BIT(11) /* asynchronous schedule park mode enable */
92#define CMD_FS2 BIT(10) /* frame list size */
93#define CMD_ASP1 BIT(9) /* asynchronous schedule park mode count */
94#define CMD_ASP0 BIT(8)
95#define CMD_LR BIT(7) /* light host/device controller reset */
96#define CMD_IAA BIT(6) /* interrupt on async advance doorbell */
97#define CMD_ASE BIT(5) /* asynchronous schedule enable */
98#define CMD_PSE BIT(4) /* periodic schedule enable */
99#define CMD_FS1 BIT(3)
100#define CMD_FS0 BIT(2)
101#define CMD_RST BIT(1) /* controller reset */
102#define CMD_RUNSTOP BIT(0) /* run/stop */
103 u32 usbsts;
104#define STS_PPCI(u) \
105 (((u)>>16)&0xffff) /* bits 31:16, port-n change detect */
106#define STS_AS BIT(15) /* asynchronous schedule status */
107#define STS_PS BIT(14) /* periodic schedule status */
108#define STS_RCL BIT(13) /* reclamation */
109#define STS_HCH BIT(12) /* HC halted */
110#define STS_ULPII BIT(10) /* ULPI interrupt */
111#define STS_SLI BIT(8) /* DC suspend */
112#define STS_SRI BIT(7) /* SOF received */
113#define STS_URI BIT(6) /* USB reset received */
114#define STS_AAI BIT(5) /* interrupt on async advance */
115#define STS_SEI BIT(4) /* system error */
116#define STS_FRI BIT(3) /* frame list rollover */
117#define STS_PCI BIT(2) /* port change detect */
118#define STS_UEI BIT(1) /* USB error interrupt */
119#define STS_UI BIT(0) /* USB interrupt */
120 u32 usbintr;
121/* bits 31:16, per-port interrupt enable */
122#define INTR_PPCE(u) (((u)>>16)&0xffff)
123#define INTR_ULPIE BIT(10) /* ULPI enable */
124#define INTR_SLE BIT(8) /* DC sleep/suspend enable */
125#define INTR_SRE BIT(7) /* SOF received enable */
126#define INTR_URE BIT(6) /* USB reset enable */
127#define INTR_AAE BIT(5) /* interrupt on async advance enable */
128#define INTR_SEE BIT(4) /* system error enable */
129#define INTR_FRE BIT(3) /* frame list rollover enable */
130#define INTR_PCE BIT(2) /* port change detect enable */
131#define INTR_UEE BIT(1) /* USB error interrupt enable */
132#define INTR_UE BIT(0) /* USB interrupt enable */
133 u32 frindex; /* frame index */
134#define FRINDEX_MASK (0x3fff << 0)
135 u32 ctrldssegment; /* not used */
136 u32 deviceaddr;
137#define USBADR_SHIFT 25
138#define USBADR(d) \
139 (((d)>>25)&0x7f) /* bits 31:25, device address */
140#define USBADR_MASK (0x7f << 25)
141#define USBADRA BIT(24) /* device address advance */
142 u32 endpointlistaddr;/* endpoint list top memory address */
143/* bits 31:11, endpoint list pointer */
144#define EPBASE(d) (((d)>>11)&0x1fffff)
145#define ENDPOINTLISTADDR_MASK (0x1fffff << 11)
146 u32 ttctrl; /* H: TT operatin, not used */
147 /* offset: 0x50 */
148 u32 burstsize; /* burst size of data movement */
149#define TXPBURST(b) \
150 (((b)>>8)&0xff) /* bits 15:8, TX burst length */
151#define RXPBURST(b) \
152 (((b)>>0)&0xff) /* bits 7:0, RX burst length */
153 u32 txfilltuning; /* TX tuning */
154 u32 txttfilltuning; /* H: TX TT tuning */
155 u32 ic_usb; /* control the IC_USB FS/LS transceiver */
156 /* offset: 0x60 */
157 u32 ulpi_viewport; /* indirect access to ULPI PHY */
158#define ULPIWU BIT(31) /* ULPI wakeup */
159#define ULPIRUN BIT(30) /* ULPI read/write run */
160#define ULPIRW BIT(29) /* ULPI read/write control */
161#define ULPISS BIT(27) /* ULPI sync state */
162#define ULPIPORT(u) \
163 (((u)>>24)&7) /* bits 26:24, ULPI port number */
164#define ULPIADDR(u) \
165 (((u)>>16)&0xff) /* bits 23:16, ULPI data address */
166#define ULPIDATRD(u) \
167 (((u)>>8)&0xff) /* bits 15:8, ULPI data read */
168#define ULPIDATWR(u) \
169 (((u)>>0)&0xff) /* bits 7:0, ULPI date write */
170 u8 _reserved6[0x70-0x64];
171 /* offset: 0x70 */
172 u32 configflag; /* H: not used */
173 u32 portsc1; /* port status */
174#define DA(p) \
175 (((p)>>25)&0x7f) /* bits 31:25, device address */
176#define PORTS_SSTS (BIT(24) | BIT(23)) /* suspend status */
177#define PORTS_WKOC BIT(22) /* wake on over-current enable */
178#define PORTS_WKDS BIT(21) /* wake on disconnect enable */
179#define PORTS_WKCN BIT(20) /* wake on connect enable */
180#define PORTS_PTC(p) (((p)>>16)&0xf) /* bits 19:16, port test control */
181#define PORTS_PIC (BIT(15) | BIT(14)) /* port indicator control */
182#define PORTS_PO BIT(13) /* port owner */
183#define PORTS_PP BIT(12) /* port power */
184#define PORTS_LS (BIT(11) | BIT(10)) /* line status */
185#define PORTS_SLP BIT(9) /* suspend using L1 */
186#define PORTS_PR BIT(8) /* port reset */
187#define PORTS_SUSP BIT(7) /* suspend */
188#define PORTS_FPR BIT(6) /* force port resume */
189#define PORTS_OCC BIT(5) /* over-current change */
190#define PORTS_OCA BIT(4) /* over-current active */
191#define PORTS_PEC BIT(3) /* port enable/disable change */
192#define PORTS_PE BIT(2) /* port enable/disable */
193#define PORTS_CSC BIT(1) /* connect status change */
194#define PORTS_CCS BIT(0) /* current connect status */
195 u8 _reserved7[0xb4-0x78];
196 /* offset: 0xb4 */
197 u32 devlc; /* control LPM and each USB port behavior */
198/* bits 31:29, parallel transceiver select */
199#define LPM_PTS(d) (((d)>>29)&7)
200#define LPM_STS BIT(28) /* serial transceiver select */
201#define LPM_PTW BIT(27) /* parallel transceiver width */
202#define LPM_PSPD(d) (((d)>>25)&3) /* bits 26:25, port speed */
203#define LPM_PSPD_MASK (BIT(26) | BIT(25))
204#define LPM_SPEED_FULL 0
205#define LPM_SPEED_LOW 1
206#define LPM_SPEED_HIGH 2
207#define LPM_SRT BIT(24) /* shorten reset time */
208#define LPM_PFSC BIT(23) /* port force full speed connect */
209#define LPM_PHCD BIT(22) /* PHY low power suspend clock disable */
210#define LPM_STL BIT(16) /* STALL reply to LPM token */
211#define LPM_BA(d) \
212 (((d)>>1)&0x7ff) /* bits 11:1, BmAttributes */
213#define LPM_NYT_ACK BIT(0) /* NYET/ACK reply to LPM token */
214 u8 _reserved8[0xf4-0xb8];
215 /* offset: 0xf4 */
216 u32 otgsc; /* On-The-Go status and control */
217#define OTGSC_DPIE BIT(30) /* data pulse interrupt enable */
218#define OTGSC_MSE BIT(29) /* 1 ms timer interrupt enable */
219#define OTGSC_BSEIE BIT(28) /* B session end interrupt enable */
220#define OTGSC_BSVIE BIT(27) /* B session valid interrupt enable */
221#define OTGSC_ASVIE BIT(26) /* A session valid interrupt enable */
222#define OTGSC_AVVIE BIT(25) /* A VBUS valid interrupt enable */
223#define OTGSC_IDIE BIT(24) /* USB ID interrupt enable */
224#define OTGSC_DPIS BIT(22) /* data pulse interrupt status */
225#define OTGSC_MSS BIT(21) /* 1 ms timer interrupt status */
226#define OTGSC_BSEIS BIT(20) /* B session end interrupt status */
227#define OTGSC_BSVIS BIT(19) /* B session valid interrupt status */
228#define OTGSC_ASVIS BIT(18) /* A session valid interrupt status */
229#define OTGSC_AVVIS BIT(17) /* A VBUS valid interrupt status */
230#define OTGSC_IDIS BIT(16) /* USB ID interrupt status */
231#define OTGSC_DPS BIT(14) /* data bus pulsing status */
232#define OTGSC_MST BIT(13) /* 1 ms timer toggle */
233#define OTGSC_BSE BIT(12) /* B session end */
234#define OTGSC_BSV BIT(11) /* B session valid */
235#define OTGSC_ASV BIT(10) /* A session valid */
236#define OTGSC_AVV BIT(9) /* A VBUS valid */
237#define OTGSC_USBID BIT(8) /* USB ID */
238#define OTGSC_HABA BIT(7) /* hw assist B-disconnect to A-connect */
239#define OTGSC_HADP BIT(6) /* hw assist data pulse */
240#define OTGSC_IDPU BIT(5) /* ID pullup */
241#define OTGSC_DP BIT(4) /* data pulsing */
242#define OTGSC_OT BIT(3) /* OTG termination */
243#define OTGSC_HAAR BIT(2) /* hw assist auto reset */
244#define OTGSC_VC BIT(1) /* VBUS charge */
245#define OTGSC_VD BIT(0) /* VBUS discharge */
246 u32 usbmode;
247#define MODE_VBPS BIT(5) /* R/W VBUS power select */
248#define MODE_SDIS BIT(4) /* R/W stream disable mode */
249#define MODE_SLOM BIT(3) /* R/W setup lockout mode */
250#define MODE_ENSE BIT(2) /* endian select */
251#define MODE_CM(u) (((u)>>0)&3) /* bits 1:0, controller mode */
252#define MODE_IDLE 0
253#define MODE_DEVICE 2
254#define MODE_HOST 3
255 u8 _reserved9[0x100-0xfc];
256 /* offset: 0x100 */
257 u32 endptnak;
258#define EPTN(e) \
259 (((e)>>16)&0xffff) /* bits 31:16, TX endpoint NAK */
260#define EPRN(e) \
261 (((e)>>0)&0xffff) /* bits 15:0, RX endpoint NAK */
262 u32 endptnaken;
263#define EPTNE(e) \
264 (((e)>>16)&0xffff) /* bits 31:16, TX endpoint NAK enable */
265#define EPRNE(e) \
266 (((e)>>0)&0xffff) /* bits 15:0, RX endpoint NAK enable */
267 u32 endptsetupstat;
268#define SETUPSTAT_MASK (0xffff << 0) /* bits 15:0 */
269#define EP0SETUPSTAT_MASK 1
270 u32 endptprime;
271/* bits 31:16, prime endpoint transmit buffer */
272#define PETB(e) (((e)>>16)&0xffff)
273/* bits 15:0, prime endpoint receive buffer */
274#define PERB(e) (((e)>>0)&0xffff)
275 /* offset: 0x110 */
276 u32 endptflush;
277/* bits 31:16, flush endpoint transmit buffer */
278#define FETB(e) (((e)>>16)&0xffff)
279/* bits 15:0, flush endpoint receive buffer */
280#define FERB(e) (((e)>>0)&0xffff)
281 u32 endptstat;
282/* bits 31:16, endpoint transmit buffer ready */
283#define ETBR(e) (((e)>>16)&0xffff)
284/* bits 15:0, endpoint receive buffer ready */
285#define ERBR(e) (((e)>>0)&0xffff)
286 u32 endptcomplete;
287/* bits 31:16, endpoint transmit complete event */
288#define ETCE(e) (((e)>>16)&0xffff)
289/* bits 15:0, endpoint receive complete event */
290#define ERCE(e) (((e)>>0)&0xffff)
291 /* offset: 0x11c */
292 u32 endptctrl[16];
293#define EPCTRL_TXE BIT(23) /* TX endpoint enable */
294#define EPCTRL_TXR BIT(22) /* TX data toggle reset */
295#define EPCTRL_TXI BIT(21) /* TX data toggle inhibit */
296#define EPCTRL_TXT(e) (((e)>>18)&3) /* bits 19:18, TX endpoint type */
297#define EPCTRL_TXT_SHIFT 18
298#define EPCTRL_TXD BIT(17) /* TX endpoint data source */
299#define EPCTRL_TXS BIT(16) /* TX endpoint STALL */
300#define EPCTRL_RXE BIT(7) /* RX endpoint enable */
301#define EPCTRL_RXR BIT(6) /* RX data toggle reset */
302#define EPCTRL_RXI BIT(5) /* RX data toggle inhibit */
303#define EPCTRL_RXT(e) (((e)>>2)&3) /* bits 3:2, RX endpoint type */
304#define EPCTRL_RXT_SHIFT 2 /* bits 19:18, TX endpoint type */
305#define EPCTRL_RXD BIT(1) /* RX endpoint data sink */
306#define EPCTRL_RXS BIT(0) /* RX endpoint STALL */
307} __attribute__ ((packed));
308
309#endif /* __LANGWELL_UDC_H */
310
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
new file mode 100644
index 00000000000..c8c52e3c91d
--- /dev/null
+++ b/include/linux/usb/midi.h
@@ -0,0 +1,112 @@
1/*
2 * <linux/usb/midi.h> -- USB MIDI definitions.
3 *
4 * Copyright (C) 2006 Thumtronics Pty Ltd.
5 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com>
7 *
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
10 *
11 * This file holds USB constants and structures defined
12 * by the USB Device Class Definition for MIDI Devices.
13 * Comments below reference relevant sections of that document:
14 *
15 * http://www.usb.org/developers/devclass_docs/midi10.pdf
16 */
17
18#ifndef __LINUX_USB_MIDI_H
19#define __LINUX_USB_MIDI_H
20
21#include <linux/types.h>
22
23/* A.1 MS Class-Specific Interface Descriptor Subtypes */
24#define USB_MS_HEADER 0x01
25#define USB_MS_MIDI_IN_JACK 0x02
26#define USB_MS_MIDI_OUT_JACK 0x03
27#define USB_MS_ELEMENT 0x04
28
29/* A.2 MS Class-Specific Endpoint Descriptor Subtypes */
30#define USB_MS_GENERAL 0x01
31
32/* A.3 MS MIDI IN and OUT Jack Types */
33#define USB_MS_EMBEDDED 0x01
34#define USB_MS_EXTERNAL 0x02
35
36/* 6.1.2.1 Class-Specific MS Interface Header Descriptor */
37struct usb_ms_header_descriptor {
38 __u8 bLength;
39 __u8 bDescriptorType;
40 __u8 bDescriptorSubtype;
41 __le16 bcdMSC;
42 __le16 wTotalLength;
43} __attribute__ ((packed));
44
45#define USB_DT_MS_HEADER_SIZE 7
46
47/* 6.1.2.2 MIDI IN Jack Descriptor */
48struct usb_midi_in_jack_descriptor {
49 __u8 bLength;
50 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
51 __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */
52 __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
53 __u8 bJackID;
54 __u8 iJack;
55} __attribute__ ((packed));
56
57#define USB_DT_MIDI_IN_SIZE 6
58
59struct usb_midi_source_pin {
60 __u8 baSourceID;
61 __u8 baSourcePin;
62} __attribute__ ((packed));
63
64/* 6.1.2.3 MIDI OUT Jack Descriptor */
65struct usb_midi_out_jack_descriptor {
66 __u8 bLength;
67 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
68 __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */
69 __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
70 __u8 bJackID;
71 __u8 bNrInputPins; /* p */
72 struct usb_midi_source_pin pins[]; /* [p] */
73 /*__u8 iJack; -- omitted due to variable-sized pins[] */
74} __attribute__ ((packed));
75
76#define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
77
78/* As above, but more useful for defining your own descriptors: */
79#define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p) \
80struct usb_midi_out_jack_descriptor_##p { \
81 __u8 bLength; \
82 __u8 bDescriptorType; \
83 __u8 bDescriptorSubtype; \
84 __u8 bJackType; \
85 __u8 bJackID; \
86 __u8 bNrInputPins; \
87 struct usb_midi_source_pin pins[p]; \
88 __u8 iJack; \
89} __attribute__ ((packed))
90
91/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */
92struct usb_ms_endpoint_descriptor {
93 __u8 bLength; /* 4+n */
94 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
95 __u8 bDescriptorSubtype; /* USB_MS_GENERAL */
96 __u8 bNumEmbMIDIJack; /* n */
97 __u8 baAssocJackID[]; /* [n] */
98} __attribute__ ((packed));
99
100#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
101
102/* As above, but more useful for defining your own descriptors: */
103#define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n) \
104struct usb_ms_endpoint_descriptor_##n { \
105 __u8 bLength; \
106 __u8 bDescriptorType; \
107 __u8 bDescriptorSubtype; \
108 __u8 bNumEmbMIDIJack; \
109 __u8 baAssocJackID[n]; \
110} __attribute__ ((packed))
111
112#endif /* __LINUX_USB_MIDI_H */
diff --git a/include/linux/usb/otg_id.h b/include/linux/usb/otg_id.h
new file mode 100644
index 00000000000..f9f5189a73b
--- /dev/null
+++ b/include/linux/usb/otg_id.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright (C) 2011 Google, Inc.
3 *
4 * Author:
5 * Colin Cross <ccross@android.com>
6 *
7 * This software is licensed under the terms of the GNU General Public
8 * License version 2, as published by the Free Software Foundation, and
9 * may be copied, distributed, and modified under those terms.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 */
17
18#ifndef __LINUX_USB_OTG_ID_H
19#define __LINUX_USB_OTG_ID_H
20
21#include <linux/notifier.h>
22#include <linux/plist.h>
23
24/**
25 * otg_id_notifier_block
26 *
27 * @priority: Order the notifications will be called in. Higher numbers
28 * get called first.
29 * @detect: Called during otg_id_notify. Return OTG_ID_HANDLED if the USB cable
30 * has been identified
31 * @proxy_wait: Called during otg_id_notify if a previous handler returns
32 * OTG_ID_PROXY_WAIT. This should wait on ID change then call otg_id_notify.
33 * This is used when a handler knows what's connected but can't detect
34 * the change itself.
35 * @cancel: Called after detect has returned OTG_ID_HANDLED to ask it to
36 * release detection resources to allow a new identification to occur.
37 */
38
39struct otg_id_notifier_block {
40 int priority;
41 int (*detect)(struct otg_id_notifier_block *otg_id_nb);
42 int (*proxy_wait)(struct otg_id_notifier_block *otg_id_nb);
43 void (*cancel)(struct otg_id_notifier_block *otg_id_nb);
44 struct plist_node p;
45};
46
47#define OTG_ID_PROXY_WAIT 2
48#define OTG_ID_HANDLED 1
49#define OTG_ID_UNHANDLED 0
50
51int otg_id_register_notifier(struct otg_id_notifier_block *otg_id_nb);
52void otg_id_unregister_notifier(struct otg_id_notifier_block *otg_id_nb);
53
54void otg_id_notify(void);
55int otg_id_suspend(void);
56void otg_id_resume(void);
57
58#endif /* __LINUX_USB_OTG_ID_H */
diff --git a/include/linux/usb/tmc.h b/include/linux/usb/tmc.h
new file mode 100644
index 00000000000..c045ae12556
--- /dev/null
+++ b/include/linux/usb/tmc.h
@@ -0,0 +1,43 @@
1/*
2 * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany
3 * Copyright (C) 2008 Novell, Inc.
4 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This file holds USB constants defined by the USB Device Class
7 * Definition for Test and Measurement devices published by the USB-IF.
8 *
9 * It also has the ioctl definitions for the usbtmc kernel driver that
10 * userspace needs to know about.
11 */
12
13#ifndef __LINUX_USB_TMC_H
14#define __LINUX_USB_TMC_H
15
16/* USB TMC status values */
17#define USBTMC_STATUS_SUCCESS 0x01
18#define USBTMC_STATUS_PENDING 0x02
19#define USBTMC_STATUS_FAILED 0x80
20#define USBTMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
21#define USBTMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
22#define USBTMC_STATUS_SPLIT_IN_PROGRESS 0x83
23
24/* USB TMC requests values */
25#define USBTMC_REQUEST_INITIATE_ABORT_BULK_OUT 1
26#define USBTMC_REQUEST_CHECK_ABORT_BULK_OUT_STATUS 2
27#define USBTMC_REQUEST_INITIATE_ABORT_BULK_IN 3
28#define USBTMC_REQUEST_CHECK_ABORT_BULK_IN_STATUS 4
29#define USBTMC_REQUEST_INITIATE_CLEAR 5
30#define USBTMC_REQUEST_CHECK_CLEAR_STATUS 6
31#define USBTMC_REQUEST_GET_CAPABILITIES 7
32#define USBTMC_REQUEST_INDICATOR_PULSE 64
33
34/* Request values for USBTMC driver's ioctl entry point */
35#define USBTMC_IOC_NR 91
36#define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1)
37#define USBTMC_IOCTL_CLEAR _IO(USBTMC_IOC_NR, 2)
38#define USBTMC_IOCTL_ABORT_BULK_OUT _IO(USBTMC_IOC_NR, 3)
39#define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4)
40#define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6)
41#define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
42
43#endif
diff --git a/include/linux/usb/video.h b/include/linux/usb/video.h
new file mode 100644
index 00000000000..3b3b95e01f7
--- /dev/null
+++ b/include/linux/usb/video.h
@@ -0,0 +1,568 @@
1/*
2 * USB Video Class definitions.
3 *
4 * Copyright (C) 2009 Laurent Pinchart <laurent.pinchart@skynet.be>
5 *
6 * This file holds USB constants and structures defined by the USB Device
7 * Class Definition for Video Devices. Unless otherwise stated, comments
8 * below reference relevant sections of the USB Video Class 1.1 specification
9 * available at
10 *
11 * http://www.usb.org/developers/devclass_docs/USB_Video_Class_1_1.zip
12 */
13
14#ifndef __LINUX_USB_VIDEO_H
15#define __LINUX_USB_VIDEO_H
16
17#include <linux/types.h>
18
19/* --------------------------------------------------------------------------
20 * UVC constants
21 */
22
23/* A.2. Video Interface Subclass Codes */
24#define UVC_SC_UNDEFINED 0x00
25#define UVC_SC_VIDEOCONTROL 0x01
26#define UVC_SC_VIDEOSTREAMING 0x02
27#define UVC_SC_VIDEO_INTERFACE_COLLECTION 0x03
28
29/* A.3. Video Interface Protocol Codes */
30#define UVC_PC_PROTOCOL_UNDEFINED 0x00
31
32/* A.5. Video Class-Specific VC Interface Descriptor Subtypes */
33#define UVC_VC_DESCRIPTOR_UNDEFINED 0x00
34#define UVC_VC_HEADER 0x01
35#define UVC_VC_INPUT_TERMINAL 0x02
36#define UVC_VC_OUTPUT_TERMINAL 0x03
37#define UVC_VC_SELECTOR_UNIT 0x04
38#define UVC_VC_PROCESSING_UNIT 0x05
39#define UVC_VC_EXTENSION_UNIT 0x06
40
41/* A.6. Video Class-Specific VS Interface Descriptor Subtypes */
42#define UVC_VS_UNDEFINED 0x00
43#define UVC_VS_INPUT_HEADER 0x01
44#define UVC_VS_OUTPUT_HEADER 0x02
45#define UVC_VS_STILL_IMAGE_FRAME 0x03
46#define UVC_VS_FORMAT_UNCOMPRESSED 0x04
47#define UVC_VS_FRAME_UNCOMPRESSED 0x05
48#define UVC_VS_FORMAT_MJPEG 0x06
49#define UVC_VS_FRAME_MJPEG 0x07
50#define UVC_VS_FORMAT_MPEG2TS 0x0a
51#define UVC_VS_FORMAT_DV 0x0c
52#define UVC_VS_COLORFORMAT 0x0d
53#define UVC_VS_FORMAT_FRAME_BASED 0x10
54#define UVC_VS_FRAME_FRAME_BASED 0x11
55#define UVC_VS_FORMAT_STREAM_BASED 0x12
56
57/* A.7. Video Class-Specific Endpoint Descriptor Subtypes */
58#define UVC_EP_UNDEFINED 0x00
59#define UVC_EP_GENERAL 0x01
60#define UVC_EP_ENDPOINT 0x02
61#define UVC_EP_INTERRUPT 0x03
62
63/* A.8. Video Class-Specific Request Codes */
64#define UVC_RC_UNDEFINED 0x00
65#define UVC_SET_CUR 0x01
66#define UVC_GET_CUR 0x81
67#define UVC_GET_MIN 0x82
68#define UVC_GET_MAX 0x83
69#define UVC_GET_RES 0x84
70#define UVC_GET_LEN 0x85
71#define UVC_GET_INFO 0x86
72#define UVC_GET_DEF 0x87
73
74/* A.9.1. VideoControl Interface Control Selectors */
75#define UVC_VC_CONTROL_UNDEFINED 0x00
76#define UVC_VC_VIDEO_POWER_MODE_CONTROL 0x01
77#define UVC_VC_REQUEST_ERROR_CODE_CONTROL 0x02
78
79/* A.9.2. Terminal Control Selectors */
80#define UVC_TE_CONTROL_UNDEFINED 0x00
81
82/* A.9.3. Selector Unit Control Selectors */
83#define UVC_SU_CONTROL_UNDEFINED 0x00
84#define UVC_SU_INPUT_SELECT_CONTROL 0x01
85
86/* A.9.4. Camera Terminal Control Selectors */
87#define UVC_CT_CONTROL_UNDEFINED 0x00
88#define UVC_CT_SCANNING_MODE_CONTROL 0x01
89#define UVC_CT_AE_MODE_CONTROL 0x02
90#define UVC_CT_AE_PRIORITY_CONTROL 0x03
91#define UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
92#define UVC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
93#define UVC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
94#define UVC_CT_FOCUS_RELATIVE_CONTROL 0x07
95#define UVC_CT_FOCUS_AUTO_CONTROL 0x08
96#define UVC_CT_IRIS_ABSOLUTE_CONTROL 0x09
97#define UVC_CT_IRIS_RELATIVE_CONTROL 0x0a
98#define UVC_CT_ZOOM_ABSOLUTE_CONTROL 0x0b
99#define UVC_CT_ZOOM_RELATIVE_CONTROL 0x0c
100#define UVC_CT_PANTILT_ABSOLUTE_CONTROL 0x0d
101#define UVC_CT_PANTILT_RELATIVE_CONTROL 0x0e
102#define UVC_CT_ROLL_ABSOLUTE_CONTROL 0x0f
103#define UVC_CT_ROLL_RELATIVE_CONTROL 0x10
104#define UVC_CT_PRIVACY_CONTROL 0x11
105
106/* A.9.5. Processing Unit Control Selectors */
107#define UVC_PU_CONTROL_UNDEFINED 0x00
108#define UVC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
109#define UVC_PU_BRIGHTNESS_CONTROL 0x02
110#define UVC_PU_CONTRAST_CONTROL 0x03
111#define UVC_PU_GAIN_CONTROL 0x04
112#define UVC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
113#define UVC_PU_HUE_CONTROL 0x06
114#define UVC_PU_SATURATION_CONTROL 0x07
115#define UVC_PU_SHARPNESS_CONTROL 0x08
116#define UVC_PU_GAMMA_CONTROL 0x09
117#define UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0a
118#define UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0b
119#define UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0c
120#define UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0d
121#define UVC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0e
122#define UVC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0f
123#define UVC_PU_HUE_AUTO_CONTROL 0x10
124#define UVC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
125#define UVC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
126
127/* A.9.7. VideoStreaming Interface Control Selectors */
128#define UVC_VS_CONTROL_UNDEFINED 0x00
129#define UVC_VS_PROBE_CONTROL 0x01
130#define UVC_VS_COMMIT_CONTROL 0x02
131#define UVC_VS_STILL_PROBE_CONTROL 0x03
132#define UVC_VS_STILL_COMMIT_CONTROL 0x04
133#define UVC_VS_STILL_IMAGE_TRIGGER_CONTROL 0x05
134#define UVC_VS_STREAM_ERROR_CODE_CONTROL 0x06
135#define UVC_VS_GENERATE_KEY_FRAME_CONTROL 0x07
136#define UVC_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x08
137#define UVC_VS_SYNC_DELAY_CONTROL 0x09
138
139/* B.1. USB Terminal Types */
140#define UVC_TT_VENDOR_SPECIFIC 0x0100
141#define UVC_TT_STREAMING 0x0101
142
143/* B.2. Input Terminal Types */
144#define UVC_ITT_VENDOR_SPECIFIC 0x0200
145#define UVC_ITT_CAMERA 0x0201
146#define UVC_ITT_MEDIA_TRANSPORT_INPUT 0x0202
147
148/* B.3. Output Terminal Types */
149#define UVC_OTT_VENDOR_SPECIFIC 0x0300
150#define UVC_OTT_DISPLAY 0x0301
151#define UVC_OTT_MEDIA_TRANSPORT_OUTPUT 0x0302
152
153/* B.4. External Terminal Types */
154#define UVC_EXTERNAL_VENDOR_SPECIFIC 0x0400
155#define UVC_COMPOSITE_CONNECTOR 0x0401
156#define UVC_SVIDEO_CONNECTOR 0x0402
157#define UVC_COMPONENT_CONNECTOR 0x0403
158
159/* 2.4.2.2. Status Packet Type */
160#define UVC_STATUS_TYPE_CONTROL 1
161#define UVC_STATUS_TYPE_STREAMING 2
162
163/* 2.4.3.3. Payload Header Information */
164#define UVC_STREAM_EOH (1 << 7)
165#define UVC_STREAM_ERR (1 << 6)
166#define UVC_STREAM_STI (1 << 5)
167#define UVC_STREAM_RES (1 << 4)
168#define UVC_STREAM_SCR (1 << 3)
169#define UVC_STREAM_PTS (1 << 2)
170#define UVC_STREAM_EOF (1 << 1)
171#define UVC_STREAM_FID (1 << 0)
172
173/* 4.1.2. Control Capabilities */
174#define UVC_CONTROL_CAP_GET (1 << 0)
175#define UVC_CONTROL_CAP_SET (1 << 1)
176#define UVC_CONTROL_CAP_DISABLED (1 << 2)
177#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
178#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
179
180/* ------------------------------------------------------------------------
181 * UVC structures
182 */
183
184/* All UVC descriptors have these 3 fields at the beginning */
185struct uvc_descriptor_header {
186 __u8 bLength;
187 __u8 bDescriptorType;
188 __u8 bDescriptorSubType;
189} __attribute__((packed));
190
191/* 3.7.2. Video Control Interface Header Descriptor */
192struct uvc_header_descriptor {
193 __u8 bLength;
194 __u8 bDescriptorType;
195 __u8 bDescriptorSubType;
196 __u16 bcdUVC;
197 __u16 wTotalLength;
198 __u32 dwClockFrequency;
199 __u8 bInCollection;
200 __u8 baInterfaceNr[];
201} __attribute__((__packed__));
202
203#define UVC_DT_HEADER_SIZE(n) (12+(n))
204
205#define UVC_HEADER_DESCRIPTOR(n) \
206 uvc_header_descriptor_##n
207
208#define DECLARE_UVC_HEADER_DESCRIPTOR(n) \
209struct UVC_HEADER_DESCRIPTOR(n) { \
210 __u8 bLength; \
211 __u8 bDescriptorType; \
212 __u8 bDescriptorSubType; \
213 __u16 bcdUVC; \
214 __u16 wTotalLength; \
215 __u32 dwClockFrequency; \
216 __u8 bInCollection; \
217 __u8 baInterfaceNr[n]; \
218} __attribute__ ((packed))
219
220/* 3.7.2.1. Input Terminal Descriptor */
221struct uvc_input_terminal_descriptor {
222 __u8 bLength;
223 __u8 bDescriptorType;
224 __u8 bDescriptorSubType;
225 __u8 bTerminalID;
226 __u16 wTerminalType;
227 __u8 bAssocTerminal;
228 __u8 iTerminal;
229} __attribute__((__packed__));
230
231#define UVC_DT_INPUT_TERMINAL_SIZE 8
232
233/* 3.7.2.2. Output Terminal Descriptor */
234struct uvc_output_terminal_descriptor {
235 __u8 bLength;
236 __u8 bDescriptorType;
237 __u8 bDescriptorSubType;
238 __u8 bTerminalID;
239 __u16 wTerminalType;
240 __u8 bAssocTerminal;
241 __u8 bSourceID;
242 __u8 iTerminal;
243} __attribute__((__packed__));
244
245#define UVC_DT_OUTPUT_TERMINAL_SIZE 9
246
247/* 3.7.2.3. Camera Terminal Descriptor */
248struct uvc_camera_terminal_descriptor {
249 __u8 bLength;
250 __u8 bDescriptorType;
251 __u8 bDescriptorSubType;
252 __u8 bTerminalID;
253 __u16 wTerminalType;
254 __u8 bAssocTerminal;
255 __u8 iTerminal;
256 __u16 wObjectiveFocalLengthMin;
257 __u16 wObjectiveFocalLengthMax;
258 __u16 wOcularFocalLength;
259 __u8 bControlSize;
260 __u8 bmControls[3];
261} __attribute__((__packed__));
262
263#define UVC_DT_CAMERA_TERMINAL_SIZE(n) (15+(n))
264
265/* 3.7.2.4. Selector Unit Descriptor */
266struct uvc_selector_unit_descriptor {
267 __u8 bLength;
268 __u8 bDescriptorType;
269 __u8 bDescriptorSubType;
270 __u8 bUnitID;
271 __u8 bNrInPins;
272 __u8 baSourceID[0];
273 __u8 iSelector;
274} __attribute__((__packed__));
275
276#define UVC_DT_SELECTOR_UNIT_SIZE(n) (6+(n))
277
278#define UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
279 uvc_selector_unit_descriptor_##n
280
281#define DECLARE_UVC_SELECTOR_UNIT_DESCRIPTOR(n) \
282struct UVC_SELECTOR_UNIT_DESCRIPTOR(n) { \
283 __u8 bLength; \
284 __u8 bDescriptorType; \
285 __u8 bDescriptorSubType; \
286 __u8 bUnitID; \
287 __u8 bNrInPins; \
288 __u8 baSourceID[n]; \
289 __u8 iSelector; \
290} __attribute__ ((packed))
291
292/* 3.7.2.5. Processing Unit Descriptor */
293struct uvc_processing_unit_descriptor {
294 __u8 bLength;
295 __u8 bDescriptorType;
296 __u8 bDescriptorSubType;
297 __u8 bUnitID;
298 __u8 bSourceID;
299 __u16 wMaxMultiplier;
300 __u8 bControlSize;
301 __u8 bmControls[2];
302 __u8 iProcessing;
303} __attribute__((__packed__));
304
305#define UVC_DT_PROCESSING_UNIT_SIZE(n) (9+(n))
306
307/* 3.7.2.6. Extension Unit Descriptor */
308struct uvc_extension_unit_descriptor {
309 __u8 bLength;
310 __u8 bDescriptorType;
311 __u8 bDescriptorSubType;
312 __u8 bUnitID;
313 __u8 guidExtensionCode[16];
314 __u8 bNumControls;
315 __u8 bNrInPins;
316 __u8 baSourceID[0];
317 __u8 bControlSize;
318 __u8 bmControls[0];
319 __u8 iExtension;
320} __attribute__((__packed__));
321
322#define UVC_DT_EXTENSION_UNIT_SIZE(p, n) (24+(p)+(n))
323
324#define UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
325 uvc_extension_unit_descriptor_##p_##n
326
327#define DECLARE_UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) \
328struct UVC_EXTENSION_UNIT_DESCRIPTOR(p, n) { \
329 __u8 bLength; \
330 __u8 bDescriptorType; \
331 __u8 bDescriptorSubType; \
332 __u8 bUnitID; \
333 __u8 guidExtensionCode[16]; \
334 __u8 bNumControls; \
335 __u8 bNrInPins; \
336 __u8 baSourceID[p]; \
337 __u8 bControlSize; \
338 __u8 bmControls[n]; \
339 __u8 iExtension; \
340} __attribute__ ((packed))
341
342/* 3.8.2.2. Video Control Interrupt Endpoint Descriptor */
343struct uvc_control_endpoint_descriptor {
344 __u8 bLength;
345 __u8 bDescriptorType;
346 __u8 bDescriptorSubType;
347 __u16 wMaxTransferSize;
348} __attribute__((__packed__));
349
350#define UVC_DT_CONTROL_ENDPOINT_SIZE 5
351
352/* 3.9.2.1. Input Header Descriptor */
353struct uvc_input_header_descriptor {
354 __u8 bLength;
355 __u8 bDescriptorType;
356 __u8 bDescriptorSubType;
357 __u8 bNumFormats;
358 __u16 wTotalLength;
359 __u8 bEndpointAddress;
360 __u8 bmInfo;
361 __u8 bTerminalLink;
362 __u8 bStillCaptureMethod;
363 __u8 bTriggerSupport;
364 __u8 bTriggerUsage;
365 __u8 bControlSize;
366 __u8 bmaControls[];
367} __attribute__((__packed__));
368
369#define UVC_DT_INPUT_HEADER_SIZE(n, p) (13+(n*p))
370
371#define UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
372 uvc_input_header_descriptor_##n_##p
373
374#define DECLARE_UVC_INPUT_HEADER_DESCRIPTOR(n, p) \
375struct UVC_INPUT_HEADER_DESCRIPTOR(n, p) { \
376 __u8 bLength; \
377 __u8 bDescriptorType; \
378 __u8 bDescriptorSubType; \
379 __u8 bNumFormats; \
380 __u16 wTotalLength; \
381 __u8 bEndpointAddress; \
382 __u8 bmInfo; \
383 __u8 bTerminalLink; \
384 __u8 bStillCaptureMethod; \
385 __u8 bTriggerSupport; \
386 __u8 bTriggerUsage; \
387 __u8 bControlSize; \
388 __u8 bmaControls[p][n]; \
389} __attribute__ ((packed))
390
391/* 3.9.2.2. Output Header Descriptor */
392struct uvc_output_header_descriptor {
393 __u8 bLength;
394 __u8 bDescriptorType;
395 __u8 bDescriptorSubType;
396 __u8 bNumFormats;
397 __u16 wTotalLength;
398 __u8 bEndpointAddress;
399 __u8 bTerminalLink;
400 __u8 bControlSize;
401 __u8 bmaControls[];
402} __attribute__((__packed__));
403
404#define UVC_DT_OUTPUT_HEADER_SIZE(n, p) (9+(n*p))
405
406#define UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
407 uvc_output_header_descriptor_##n_##p
408
409#define DECLARE_UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) \
410struct UVC_OUTPUT_HEADER_DESCRIPTOR(n, p) { \
411 __u8 bLength; \
412 __u8 bDescriptorType; \
413 __u8 bDescriptorSubType; \
414 __u8 bNumFormats; \
415 __u16 wTotalLength; \
416 __u8 bEndpointAddress; \
417 __u8 bTerminalLink; \
418 __u8 bControlSize; \
419 __u8 bmaControls[p][n]; \
420} __attribute__ ((packed))
421
422/* 3.9.2.6. Color matching descriptor */
423struct uvc_color_matching_descriptor {
424 __u8 bLength;
425 __u8 bDescriptorType;
426 __u8 bDescriptorSubType;
427 __u8 bColorPrimaries;
428 __u8 bTransferCharacteristics;
429 __u8 bMatrixCoefficients;
430} __attribute__((__packed__));
431
432#define UVC_DT_COLOR_MATCHING_SIZE 6
433
434/* 4.3.1.1. Video Probe and Commit Controls */
435struct uvc_streaming_control {
436 __u16 bmHint;
437 __u8 bFormatIndex;
438 __u8 bFrameIndex;
439 __u32 dwFrameInterval;
440 __u16 wKeyFrameRate;
441 __u16 wPFrameRate;
442 __u16 wCompQuality;
443 __u16 wCompWindowSize;
444 __u16 wDelay;
445 __u32 dwMaxVideoFrameSize;
446 __u32 dwMaxPayloadTransferSize;
447 __u32 dwClockFrequency;
448 __u8 bmFramingInfo;
449 __u8 bPreferedVersion;
450 __u8 bMinVersion;
451 __u8 bMaxVersion;
452} __attribute__((__packed__));
453
454/* Uncompressed Payload - 3.1.1. Uncompressed Video Format Descriptor */
455struct uvc_format_uncompressed {
456 __u8 bLength;
457 __u8 bDescriptorType;
458 __u8 bDescriptorSubType;
459 __u8 bFormatIndex;
460 __u8 bNumFrameDescriptors;
461 __u8 guidFormat[16];
462 __u8 bBitsPerPixel;
463 __u8 bDefaultFrameIndex;
464 __u8 bAspectRatioX;
465 __u8 bAspectRatioY;
466 __u8 bmInterfaceFlags;
467 __u8 bCopyProtect;
468} __attribute__((__packed__));
469
470#define UVC_DT_FORMAT_UNCOMPRESSED_SIZE 27
471
472/* Uncompressed Payload - 3.1.2. Uncompressed Video Frame Descriptor */
473struct uvc_frame_uncompressed {
474 __u8 bLength;
475 __u8 bDescriptorType;
476 __u8 bDescriptorSubType;
477 __u8 bFrameIndex;
478 __u8 bmCapabilities;
479 __u16 wWidth;
480 __u16 wHeight;
481 __u32 dwMinBitRate;
482 __u32 dwMaxBitRate;
483 __u32 dwMaxVideoFrameBufferSize;
484 __u32 dwDefaultFrameInterval;
485 __u8 bFrameIntervalType;
486 __u32 dwFrameInterval[];
487} __attribute__((__packed__));
488
489#define UVC_DT_FRAME_UNCOMPRESSED_SIZE(n) (26+4*(n))
490
491#define UVC_FRAME_UNCOMPRESSED(n) \
492 uvc_frame_uncompressed_##n
493
494#define DECLARE_UVC_FRAME_UNCOMPRESSED(n) \
495struct UVC_FRAME_UNCOMPRESSED(n) { \
496 __u8 bLength; \
497 __u8 bDescriptorType; \
498 __u8 bDescriptorSubType; \
499 __u8 bFrameIndex; \
500 __u8 bmCapabilities; \
501 __u16 wWidth; \
502 __u16 wHeight; \
503 __u32 dwMinBitRate; \
504 __u32 dwMaxBitRate; \
505 __u32 dwMaxVideoFrameBufferSize; \
506 __u32 dwDefaultFrameInterval; \
507 __u8 bFrameIntervalType; \
508 __u32 dwFrameInterval[n]; \
509} __attribute__ ((packed))
510
511/* MJPEG Payload - 3.1.1. MJPEG Video Format Descriptor */
512struct uvc_format_mjpeg {
513 __u8 bLength;
514 __u8 bDescriptorType;
515 __u8 bDescriptorSubType;
516 __u8 bFormatIndex;
517 __u8 bNumFrameDescriptors;
518 __u8 bmFlags;
519 __u8 bDefaultFrameIndex;
520 __u8 bAspectRatioX;
521 __u8 bAspectRatioY;
522 __u8 bmInterfaceFlags;
523 __u8 bCopyProtect;
524} __attribute__((__packed__));
525
526#define UVC_DT_FORMAT_MJPEG_SIZE 11
527
528/* MJPEG Payload - 3.1.2. MJPEG Video Frame Descriptor */
529struct uvc_frame_mjpeg {
530 __u8 bLength;
531 __u8 bDescriptorType;
532 __u8 bDescriptorSubType;
533 __u8 bFrameIndex;
534 __u8 bmCapabilities;
535 __u16 wWidth;
536 __u16 wHeight;
537 __u32 dwMinBitRate;
538 __u32 dwMaxBitRate;
539 __u32 dwMaxVideoFrameBufferSize;
540 __u32 dwDefaultFrameInterval;
541 __u8 bFrameIntervalType;
542 __u32 dwFrameInterval[];
543} __attribute__((__packed__));
544
545#define UVC_DT_FRAME_MJPEG_SIZE(n) (26+4*(n))
546
547#define UVC_FRAME_MJPEG(n) \
548 uvc_frame_mjpeg_##n
549
550#define DECLARE_UVC_FRAME_MJPEG(n) \
551struct UVC_FRAME_MJPEG(n) { \
552 __u8 bLength; \
553 __u8 bDescriptorType; \
554 __u8 bDescriptorSubType; \
555 __u8 bFrameIndex; \
556 __u8 bmCapabilities; \
557 __u16 wWidth; \
558 __u16 wHeight; \
559 __u32 dwMinBitRate; \
560 __u32 dwMaxBitRate; \
561 __u32 dwMaxVideoFrameBufferSize; \
562 __u32 dwDefaultFrameInterval; \
563 __u8 bFrameIntervalType; \
564 __u32 dwFrameInterval[n]; \
565} __attribute__ ((packed))
566
567#endif /* __LINUX_USB_VIDEO_H */
568